package com.jenings.shop.controller;

import com.jenings.shop.entity.Seller;
import com.jenings.shop.service.SellerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = {"卖家mj"})
@RestController
@RequestMapping("/sellerApi")
public class SellerController {
    @Autowired
    SellerService sellerService;
    //查询全部卖家
    @ApiOperation(value = "查询全部卖家")
    @RequestMapping(value = "/selectAll" , method = RequestMethod.POST)
    public List<Seller> selectAll(){
        List<Seller> sellerList = sellerService.selectAll();
        return sellerList;
    }
    //查询部分卖家
    @ApiOperation(value = "查询部分卖家")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mjname", value = "卖家名称", required = true, dataTypeClass = String.class)
    })
    @RequestMapping(value = "/selectSome" , method = RequestMethod.POST)
    public List<Seller> selectSome(@RequestParam(value = "mjname") String mjname){
        List<Seller> sellerList = sellerService.selectSome(mjname);
        return sellerList;
    }
    //查询固定卖家
    @ApiOperation(value = "查询指定卖家")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mjname", value = "卖家名称", required = true, dataTypeClass = String.class)
    })
    @RequestMapping(value = "/selectByte" , method = RequestMethod.POST)
    public Seller selectByte(@RequestParam(value = "mjname") String mjname){
        Seller seller = sellerService.selectByte(mjname);
        System.out.println(mjname);
        return seller;
    }
    //卖家修改个人信息
    @ApiOperation(value = "修改卖家个人信息")
    @RequestMapping(value = "/updateByte" , method = RequestMethod.POST, produces = "application/json")
    public boolean updateByte(@RequestBody Seller seller){
        return sellerService.updateByte(seller);
    }
    //添加卖家
    @ApiOperation(value = "添加卖家")
    @RequestMapping(value = "/insertByte" , method = RequestMethod.POST, produces = "application/json")
    public boolean insertByte(@RequestBody Seller seller){
        return sellerService.insertByte(seller);
    }
    //删除卖家
    @ApiOperation(value = "删除卖家")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mjid", value = "卖家id", required = true, dataTypeClass = String.class)
    })
    @RequestMapping(value = "/delByte" , method = RequestMethod.POST)
    public boolean delByte(@RequestParam(value = "mjid") Integer mjid){
        return sellerService.delByte(mjid);
    }
}
